<template>
  <div class="test">
    1
  </div>
</template>

<script>
import { Base64 } from '@/utils/base64';
export default {
  data(){
    return{
      user:{
        name:'孙悟空',
        age:18,
        role:'弼马温'
      }
    }
  },
  methods:{
    test(){
            const base=new Base64()
            let token=JSON.parse(sessionStorage.getItem('user')).token
            // console.log('token:',token,token.length);
            let last=token.lastIndexOf('.')
            let token2=token.slice(0,last)
            // console.log('token2',token2);
            let head=token.indexOf('.')
            let token3=token2.slice(head+1)
            // console.log('token3',token3);
            let str=base.decode(token3)
            let y=str.indexOf('}')
            str=str.slice(0,y+1)
          //  console.log(Object.prototype.toString.call(str));
            // let str1='{"aud":"1","exp":1680106653}'
            // console.log(Object.prototype.toString.call(str1));
            // console.log(str,str.length,str.includes(' '));
            // console.log(str1,str1.length,str1.includes(' '));
            // console.log('str==str1:',str==str1);
            let object=eval("(" + str + ")")
            console.log(object);
           
            
        },
  },
  mounted(){
    this.test()
  }
}
</script>

<style>

</style>